import sys

s = input().split(" ")
m = int(s[0])
n = int(s[1])
nums1 = [int(x) for x in input().split(" ")]
nums2 = [int(x) for x in input().split(" ")]

def findMedianSortedArrays(nums1, nums2):
    length1 = len(nums1)
    length2 = len(nums2)
    if length1 > length2:
        return findMedianSortedArrays(nums2, nums1)
    if length1 == 0:
        if length2 % 2 == 1:
            return nums2[length2 // 2]
        else:
            return (nums2[length2 // 2] + nums2[length2 // 2 - 1]) / 2
    result = 0
    L = 0
    R = length1
    curA = 0
    curB = 0
    totalLength = length1 + length2
    while L <= R:
        curA = L + (R - L) // 2;
        curB = (totalLength + 1) // 2 - curA;
        L1 = 0
        if curA == 0:
            L1 = -sys.maxsize - 1
        else:
            L1 = nums1[curA - 1]
        R1 = 0
        if curA == length1:
            R1 = sys.maxsize
        else:
            R1 = nums1[curA]
        L2 = 0
        if curB == 0:
            L2 = -sys.maxsize - 1
        else:
            L2 = nums2[curB - 1]
        R2 = 0
        if curB == length2:
            R2 = sys.maxsize
        else:
            R2 = nums2[curB]
        if L1 > R2:
            R = curA - 1
        elif L2 > R1:
            L = curA + 1
        else:
            if totalLength % 2 == 1:
                result = max(L1, L2)
            else:
                result = (max(L1, L2) + min(R1, R2)) / 2
            break
    return result
print(findMedianSortedArrays(nums1, nums2))